﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FL.Bussiness;
using FL.DBModule.Sys;
using FL.Common;
using System.Text.RegularExpressions;
using System.Text;
using System.Data;

namespace FL.Web.BackEnd
{
    public partial class chart_report : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetCtrlsInfo(GetStringFromQueryString("code", ""));
        }

        void GetCtrlsInfo(string code)
        {
            System.Data.DataTable dt = _bll.GetDataBySqlComm(string.Format("select id,data_source from t_sys_chart_report_setting where code='{0}'",code));
            if (dt != null && dt.Rows.Count > 0)
            {
                string chart_id =(dt.Rows[0].ItemArray[0].ToString());
                ChartReportSQL = dt.Rows[0].ItemArray[1].ToString();
                System.Data.DataTable parameter_dt = _bll.GetDataBySqlComm("select * from t_sys_chart_report_parameter where chart_id='" + chart_id + "'");
                System.Text.StringBuilder _ctrls = new System.Text.StringBuilder("");
                if (parameter_dt != null && parameter_dt.Rows.Count > 0)
                {
                    foreach (DataRow row in parameter_dt.Rows)
                    {
                        _ctrls.Append(string.Format("<div class=\"query_items\">按<span>{0}查询统计&nbsp;</span><input id=\"{1}\" name=\"{1}\" value=\"{2}\" type=\"text\"/><input type=\"button\" id=\"btnQueryOutput\" value=\"查询并输出\"></div>",
                                  row.ItemArray[parameter_dt.Columns["caption"].Ordinal].ToString(),
                                  row.ItemArray[parameter_dt.Columns["name"].Ordinal].ToString().Replace("@",""),
                                  row.ItemArray[parameter_dt.Columns["defalut_value"].Ordinal].ToString()
                                  ));
                    }
                }
                InputCtrls = _ctrls.ToString();
            }

        }

        public string ChartReportSQL
        {
            get;
            set;
        }
        public string InputCtrls
        {
            get;
            set;
        }
    }
}